# Maintainer: Maxime Gauduin <alucryd@archlinux.org>
# Contributor: Thomas Schneider <maxmusterm@gmail.com>

pkgname=svt-vp9
pkgver=0.3.0
pkgrel=2
pkgdesc='Scalable Video Technology VP9 encoder'
arch=(loong64 x86_64)
url=https://github.com/OpenVisualCloud/SVT-VP9
license=(BSD)
depends=(glibc)
makedepends=(
  cmake
  git
  nasm
  ninja
)
_tag=e1bbb77ed315f417002071e93789b366d9ff997e
source=(git+https://github.com/OpenVisualCloud/SVT-VP9.git#tag=${_tag})
md5sums=(SKIP)

pkgver() {
  cd SVT-VP9

  git describe --tags | sed 's/^v//'
}

prepare() {
  sed '/CMAKE_BUILD_TYPE Release/d' -i SVT-VP9/CMakeLists.txt
}

build() {
  export LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
  cmake -S SVT-VP9 -B build -G Ninja \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DBUILD_SHARED_LIBS=ON \
    -DNATIVE=OFF
  ninja -C build
}

package() {
  DESTDIR="${pkgdir}" ninja -C build install
  install -Dm 644 SVT-VP9/LICENSE.md -t "${pkgdir}"/usr/share/licenses/svt-vp9/
}

# vim: ts=2 sw=2 et:
